package com.lanou.service.imgService.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lanou.bean.resultImgBean.*;
import com.lanou.mapper.ImgMapper;
import com.lanou.service.imgService.ImgService;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by dllo on 18/3/12.
 */
@Service
public class ImgServiceImpl implements ImgService {
    @Resource
    private ImgMapper imgMapper;
    private List<Img> imgList;


    public List<Home> findHome() {
        return imgMapper.findHome();
    }

    public List<Layout> findLayout() {
        return imgMapper.findLayout();
    }

    public List<Pub> findPub() {
        return imgMapper.findPub();
    }

    public List<Room> findRoom() {
        return imgMapper.findRoom();
    }

    public List<Style> findStyle() {
        return imgMapper.findStyle();
    }

    public List<Type> findType() {
        return imgMapper.findType();
    }

    public List<Img> findImg(Integer desc,
                             Integer category,
                             Integer typeId,
                             Integer homeId,
                             Integer layoutId,
                             Integer styleId,
                             Integer publicId,
                             Integer ROSIId,
                             Integer roomId) {
        imgList =  imgMapper.findImg(
                desc,
                category,
                typeId,
                homeId,
                layoutId,
                styleId,
                publicId,
                ROSIId,
                roomId);
        return imgList;
    }

    public PageInfo<Img> findImgPage(Integer pageNo,
                                     Integer pageSize,
                                     Integer desc,
                                     Integer category,
                                     Integer typeId,
                                     Integer homeId,
                                     Integer layoutId,
                                     Integer styleId,
                                     Integer publicId,
                                     Integer ROSIId,
                                     Integer roomId) {
        pageNo = pageNo == null ? 1 : pageNo;
        pageSize = pageSize == null ? 10 : pageSize;
        PageHelper.startPage(pageNo, pageSize);
        List<Img> imgList1 = imgMapper.findImg( desc,
                                                category,
                                                typeId,
                                                homeId,
                                                layoutId,
                                                styleId,
                                                publicId,
                                                ROSIId,
                                                roomId);
        PageInfo<Img> imgPageInfo = new PageInfo<Img>(imgList1);
        return imgPageInfo;

    }

    @Override
    public PageInfo<ROSI> findROSIImgPage(Integer pageNo, Integer pageSize) {
        pageNo = pageNo == null ? 1 : pageNo;
        pageSize = pageSize == null ? 10 : pageSize;
        PageHelper.startPage(pageNo, pageSize);
        List<ROSI> rosiList = imgMapper.findROSIImg();
        PageInfo<ROSI> rosiPageInfo = new PageInfo<ROSI>(rosiList);
        return rosiPageInfo;
    }


}
